/* 
泛型约束
*/
(() => {

  interface LengthWise {
    length: number
  }
 
  function getLength<T extends LengthWise>(t: T) {
    return t.length
  }

  console.log(getLength<string>('abc'))
  // console.log(getLength<number>(123))  // error number没有length
  
})()